﻿<UserControl x:Class="TaskManager.View.TaskManagerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:views="clr-namespace:TaskManager.View" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <!-- Tasks in progress -->
    <TabControl VerticalAlignment="Stretch" MaxHeight="300">
        <TabItem Background="#FF414141">
            <TabItem.Header>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="TASK IN PROGRESS" Foreground="#FFA5A5A5" FontSize="13.333" TextAlignment="Center" />
                    <TextBlock Text="{Binding Tasks.Count, StringFormat=' ({0})'}" Foreground="#FFA5A5A5" FontSize="13.333" TextAlignment="Center"
                           Visibility="{Binding Tasks.Count, Converter={StaticResource NullToVisibilityConverter}}" />
                </StackPanel>
            </TabItem.Header>

            <TabItem.Content>
                <ItemsControl ItemsSource="{Binding Tasks}" Background="Black" Margin="0,2" VerticalAlignment="Stretch" 
                      ScrollViewer.VerticalScrollBarVisibility="Visible">
                    <ItemsControl.Template>
                        <ControlTemplate>
                            <ScrollViewer MaxHeight="300">
                                <ItemsPresenter  />
                            </ScrollViewer>
                        </ControlTemplate>
                    </ItemsControl.Template>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <views:TaskView />
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </TabItem.Content>
        </TabItem>

        <!-- Tasks history -->
        <TabItem Background="#FF414141">
            <TabItem.Header>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="TASK COMPLETED" Foreground="#FFA5A5A5" FontSize="13.333" TextAlignment="Center" />
                    <TextBlock Text="{Binding TasksLogger.Count, StringFormat=' ({0})'}" Foreground="#FFA5A5A5" FontSize="13.333" TextAlignment="Center"
                           Visibility="{Binding TasksLogger.Count, Converter={StaticResource NullToVisibilityConverter}}" />
                </StackPanel>
            </TabItem.Header>

            <TabItem.Content>
                <ItemsControl ItemsSource="{Binding TasksLogger}" Background="Black" Margin="0,2" VerticalAlignment="Stretch" 
                      ScrollViewer.VerticalScrollBarVisibility="Visible">
                    <ItemsControl.Template>
                        <ControlTemplate>
                            <ScrollViewer MaxHeight="300">
                                <ItemsPresenter />
                            </ScrollViewer>
                        </ControlTemplate>
                    </ItemsControl.Template>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <views:TaskLogView />
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </TabItem.Content>
        </TabItem>
    </TabControl>
</UserControl>
